export default {
  /* sessionStorage缓存 */
  sessionSet: function(key, value){
    if (typeof value === 'object') {
      value = JSON.stringify(value)
    }
    window.sessionStorage.setItem(key, value);
  },
  sessionGet: function(key){
    const data = window.sessionStorage.getItem(key)
    try {
      return JSON.parse(data)
    } catch (err) {
      return data
    }
  },
  /* localStorage缓存 */
  localSet: function(key, value){
    if (typeof value === 'object') {
      value = JSON.stringify(value)
    }
    window.localStorage.setItem(key, value);
  },
  localGet: function(key){
    const data = window.localStorage.getItem(key)
    try {
      return JSON.parse(data)
    } catch (err) {
      return data
    }
  }
}
